<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/static/js/si.ajax.js"></script>
<!--可搜索下拉框-start-->
<link rel="stylesheet" href="${ctx}/static/ace/css/chosen.css" />
<link rel="stylesheet" href="${ctx}/static/ace/css/ace.min.css" />
<link rel="stylesheet" href="${ctx}/static/ace/css/ace-rtl.min.css" />
<link rel="stylesheet" href="${ctx}/static/ace/css/ace-skins.min.css" />
<script type="text/javascript"
	src="${ctx}/static/ace/js/chosen.jquery.min.js"></script>
<!--[if !IE]> -->

<script type="text/javascript">
			window.jQuery || document.write("<script src='${ctx}/static/ace/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

<!-- <![endif]-->
<!--可搜索下拉框-end-->
<script type="text/javascript">
	var colType = '${colType}';

	$(document).ready(function(){
		changeInputType();
	});
	
	function changeInputType() {
		if(colType == "date") {	
			$('#start_value').focus(function(){
		    	WdatePicker({maxDate:'#F{$dp.$D(\'end_value\')}'});
		    });
			
			$('#end_value').focus(function(){
		    	WdatePicker({minDate:'#F{$dp.$D(\'start_value\')}'});
		    });
		} else if(colType == "datetime") {
			$(".where-input").focus(function(){
		    	WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
		    });
		} else if(colType == "timestamp") {
			$(".where-input").focus(function(){
		    	WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
		    });	
		} else if(colType == "time") {
			$(".where-input").focus(function(){
		    	WdatePicker({dateFmt:'HH:mm:ss'});
		    });	
		} else if(colType == "year") {
			$(".where-input").focus(function(){
				WdatePicker({dateFmt:'yyyy'});
		    });	
		}
	}
	
	function save(obj) {
		var isAll = $('#check_box').is(':checked');
		$('#content')[0].contentWindow.saveIntervalEdit(obj, isAll);
	}
	
	function tableSqlTest(submitFlag){ 
		var sql = $("#tableName").val()+" "+$("#whereCondition").val();
		 $.ajax({
		   type: "POST",
		   url: _ctx + "/task/table_sql_test.do",
		   async: false,
		   cache: false,
		   data: {
			   dsId:$("#dsId").val(),
			   schema: $("#schemaName").val(),
			   testSql:sql,
				dsUsername:'${dsUsername}',
			  	dsPasswd:'${dsPasswd}'
		   },
		   beforeSend: function(){
			  $("#testSqlBtn").val("正在验证...").attr("disabled","disabled");
	       },
		   success: function(data){
				if(data.status == 0){
					 alert(data.msg);
					 if(submitFlag){
						 sqlTestFlag = 0;
					 }
				  }else{
					  if(submitFlag){
						  sqlTestFlag= 1;
						}else{
							alert(data.msg);
						}
				  }
			  	$("#testSqlBtn").val("验证发布信息").attr("disabled",null);	
		   },
		   error:function(){
			   alert('系统异常,操作失败');
			   $("#testSqlBtn").val("验证发布信息").attr("disabled",null);
		   }
		}); 
	  }	
</script>
<div class="modal-header">
	<h4 class="modal-title">配置区间</h4>
</div>

<div class="modal-body overflow-visible">
	<div class="row">
		<div class="col-sm-12">
		
				<div class="col-sm-5">
					<input class="input-large where-input" value="${oldStartValue}" type="text" id="start_value"/>
					<!-- <input class="input-large where-input" type="text" id="start_value" onfocus="WdatePicker()"/> -->
				</div>
		
				<div class="col-sm-2" style="text-align: center;font-size:large">~</div>
		
				<div class="col-sm-5">
					<input class="input-large where-input" value="${oldEndValue}" type="text" id="end_value"/>
					<!-- <input class="input-large where-input" type="text" id="end_value" onfocus="WdatePicker({dateFmt:'HH:mm:ss'})"/> -->
				</div>

			
		</div>
		
		<div class="col-sm-12" style="margin-top: 10px;">
			<div class="col-sm-5" style="margin-top: 10px;">
				<label>
					<input id="check_box" name="form-field-checkbox" type="checkbox" class="ace" />
					<span class="lbl"> 为其他表进行相同配置</span>
				</label>
			</div>	
		</div>
	</div>
</div>
<div class="modal-footer">
	<button id="interval-save" tableId="${tableId}" type="button"
		class="btn btn-sm btn-info"
		onclick="save(this);">
		<i class="icon-ok bigger-110"></i>&nbsp;&nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;
	</button>

	<button type="button" class="btn btn-sm btn-danger"
		data-dismiss="modal">
		<i class="icon-remove bigger-110"></i>&nbsp;&nbsp;&nbsp;&nbsp;关闭&nbsp;&nbsp;
	</button>
</div>